package com.jamin.aabill.data;

import org.json.JSONObject;

import android.database.Cursor;

import com.jamin.aabill.api.BillException;
import com.jamin.aabill.api.JsonResponse;
import com.jamin.aabill.db.UserInfoTableMetaData;

public class UserInfo extends JsonResponse{


	public UserInfo(Cursor mCur){
		setID(mCur.getInt(mCur.getColumnIndex(UserInfoTableMetaData._ID)));
		setPhoneNum(mCur.getString(mCur.getColumnIndex(UserInfoTableMetaData.MOBILE)));
		setEmail(mCur.getString(mCur.getColumnIndex(UserInfoTableMetaData.EMAIL)));
		setName(mCur.getString(mCur.getColumnIndex(UserInfoTableMetaData.NICK_NAME)));
		setCreate_at(mCur.getLong(mCur.getColumnIndex(UserInfoTableMetaData.CREATE_AT)));
		setLastLogin_at(mCur.getLong(mCur.getColumnIndex(UserInfoTableMetaData.LAST_LOGIN_AT)));
		mCur.close();
	}


	public UserInfo(JSONObject jsonObj) throws BillException{
		setID(getInt("ID", jsonObj));
		setPhoneNum(getString("phoneNum", jsonObj, true));
		setEmail(getString("email", jsonObj, true));
		setName(getString("name", jsonObj, true));
		setCreate_at(getLong("created_at", jsonObj));
		setLastLogin_at(getLong("lastLogin_at", jsonObj));
	}


	private long ID;			//ID
	private String phoneNum;	//电话号
	private String email;		//邮箱
	private String password;	//密码
	private String name;		//姓名
	private long create_at;		//创建时间
	private long lastLogin_at;	//最后登录时间


	public long getID() {
		return ID;
	}
	public void setID(long iD) {
		ID = iD;
	}
	public String getPhoneNum() {
		return phoneNum;
	}
	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public long getCreate_at() {
		return create_at;
	}
	public void setCreate_at(long create_at) {
		this.create_at = create_at;
	}
	public long getLastLogin_at() {
		return lastLogin_at;
	}
	public void setLastLogin_at(long lastLogin_at) {
		this.lastLogin_at = lastLogin_at;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "UserInfo = {" + 
		"ID = '" + ID + "\'" +
		" , phoneNum = '" + phoneNum + "\'" +
		" , email = '" + email + "\'" +
		" , name = '" + name + "\'" +
		" , create_at = '" + create_at + "\'" +
		" , lastLogin_at = '" + lastLogin_at + "\'" +"}";
	}



}
